﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProductSystem.BLL.Common
{
    public static class EnumerableExtension
    {
        /// <summary>
        /// 分页
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public static List<T> Page<T>(this IEnumerable<T> source, PageInfo page)
        {
            page.TotalCount = source.Count();
            return source.Skip(page.PageSize * (page.CurPage - 1)).Take(page.PageSize).ToList();
        }
    }
}
